package com.yigang.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yigang.dao.ActivityDao;
import com.yigang.entity.Exercise;

import com.yigang.service.ActivityService;
import com.yigang.utils.ResultUtil;
@Service
@Transactional
public class ActivityServiceImpl implements ActivityService{

	@Autowired
	private ActivityDao activityDao;
	@Override
	public ResultUtil selectActivityList(Integer page, Integer limit, Exercise record) {
		// TODO Auto-generated method stub
		PageHelper.startPage(page, limit);
		List<Exercise> activity = activityDao.selectActivityList(record);
		PageInfo<Exercise> pageInfo = new PageInfo<Exercise>(activity);
		ResultUtil resultUtil = new ResultUtil();
		resultUtil.setCode(0);
		resultUtil.setCount(pageInfo.getTotal());
		resultUtil.setData(pageInfo.getList());
		return resultUtil;
	}

	@Override
	public ResultUtil deleteByPrimaryKey(Integer activity_id) {
		// TODO Auto-generated method stub
		activityDao.deleteByPrimaryKey(activity_id);
		return ResultUtil.ok();
	}

	@Override
	public ResultUtil insertSelective(Exercise record) {
		// TODO Auto-generated method stub
		activityDao.insertSelective(record);
		return ResultUtil.ok();
	}

	@Override
	public ResultUtil updateByPrimaryKeySelective(Exercise record) {
		// TODO Auto-generated method stub
		activityDao.updateByPrimaryKeySelective(record);
		return ResultUtil.ok();
	}

	@Override
	public Exercise selectActivityById(int activity_id) {
		// TODO Auto-generated method stub
		return activityDao.selectActivityById(activity_id);
	}

	
	  @Override 
	  public List<Map<String, Object>> getAllActivity() { 
		  // TODOAuto-generated method stub
	  
	  return activityDao.getAllActivity(); }
	 

}
